/*
	Nguoi tao: SonLD;
	Ngay tao : 13/4/2011;
	Muc dich : Kiem tra viec dang nhap

*/
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME='SP_KIEMTRADANGNHAP')
BEGIN
	DROP PROC SP_KIEMTRADANGNHAP
END
GO
CREATE PROC SP_KIEMTRADANGNHAP
--TAT CA CAC THAM SO INT+OUP
	@TENDANGNHAP	NVARCHAR(30),
	@MATKHAU		NVARCHAR(40),
	@RESULT			INT OUTPUT
AS
BEGIN
--CHUA DOAN LENH XU LI
	IF EXISTS (SELECT * FROM THANHVIEN WHERE TENDN=@TENDANGNHAP AND MATKHAU=@MATKHAU)
	BEGIN
		SET @RESULT=1
		PRINT 'DANG NHAP THANH CONG'
	END
	ELSE
	BEGIN
		SET @RESULT=0
		PRINT 'DANG NHAP THAT BAI'
	END
END

--THUC THI SP_KIEMTRADANGNHAP

DECLARE @TENDN NVARCHAR(30)
SET @TENDN='SONLD'
DECLARE @MATKHAU VARCHAR(40)
SET @MATKHAU='SONLD'
DECLARE @RESULT INT
EXEC SP_KIEMTRADANGNHAP @TENDN,@MATKHAU,@RESULT OUTPUT
SELECT @RESULT AS 'RESULT'

--STORED PROCEDURES KHONG THE TU CHAY